package com.tj.collection.controller.lending;

import com.alibaba.fastjson.JSONObject;
import com.tj.collection.aop.anno.VisitorAccessible;
import com.tj.collection.bean.ApiResponse;
import com.tj.collection.controller.lending.response.ClAppBaseResponse;
import com.tj.collection.utils.ConfigUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * User: pavan
 * Date: 2020/1/22
 * Time: 下午2:33
 */
@RestController
@RequestMapping("/collection/app")
public class ClAppController {

    @Autowired
    private ConfigUtil configUtil;

    /**
     * 催收模块下拉栏相关数据
     *
     * @return
     */
    @VisitorAccessible
    @RequestMapping("/base/get")
    public ApiResponse<ClAppBaseResponse> getCollectionCaseCommonInfo() {
        boolean cmAppRecordingSwitch = configUtil.getCMAppRecordingSwitch();
        JSONObject config = configUtil.getCollectionAppUpdateInfo();
        Integer latestVersionCode = config.getInteger("latestVersionCode") == null ? 0 : config.getInteger("latestVersionCode");
        Integer minimumVersionCode = config.getInteger("minimumVersionCode") == null ? 0 : config.getInteger("minimumVersionCode");
        String updateUrl = config.getString("updateUrl");
        String updateDesc = config.getString("updateDesc");
        return new ApiResponse<>(new ClAppBaseResponse(latestVersionCode, minimumVersionCode, updateUrl, updateDesc, cmAppRecordingSwitch));
    }

}
